package com.kt.emall.search.web;

import com.kt.emall.search.service.MallSearchService;
import com.kt.emall.search.vo.SearchParam;
import com.kt.emall.search.vo.SearchResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;

/**
 * @program: e-mall
 * @description: 检索功能控制层
 * @author: KamTang
 * @create: 2021-09-24 15:36
 **/
@Controller
public class SearchController {

    @Autowired
    MallSearchService mallSearchService;

    @GetMapping("/list.html")
    public String listPage(SearchParam param, Model model) {
        // 根据传过来的页面查询参数，去ES中检索商品
        SearchResult result = mallSearchService.search(param);
        model.addAttribute("result", result);
        return "list";
    }

}
